
/** Create and modify a symbol that can be added to symbol table.<br>
 * Rep: a symbol consists of a label, its location in memory, its usage, its length, 
 * and its equated symbol value. If one or more of those values does not apply to the 
 * symbol, It will contain the value of 0.
 * @author Tobin Chee, Dan Carpenter
 * Change Log:<br>
 * - 4/09/09 - Tobin Chee<br>
 * - Added and completed Symbolclass.
 */
public class Symbol {
	/** Label for symbol.
	 */
	private String label;
	/** Location of symbol in memory.
	 */
	private int location;
	/** Usage of symbol.
	 */
	private Assembler.SymbolUsage usage;
	/** length of symbol.
	 */
	private int length;
	/** equated symbol value
	 */
	private int equValue;
	

	/** Construct an empty symbol. 
	 */
	public Symbol(){
		label = "";
		location = -1;
		usage = Assembler.SymbolUsage.DATA_LABEL; //arbitrary default value
		length = 0; //May be unnecessary for our purposes
		equValue = 0;
	}
	
	/** Create a symbol with values.
	 * @param lbl Symbol to initiate.
	 * @param loc Memory location of symbol to initiate.
	 * @param use Use of symbol to initiate.
	 */
	public Symbol(String lbl, int loc, Assembler.SymbolUsage use){
		label = lbl;
		location = loc;
		usage = use;
		//Ask professor about length
		length = label.length();
	}
	
	/** Set the label of a symbol.
	 * @param lbl Label for symbol.
	 */
	public void setLabel(String lbl){
		label = lbl;	
	}
	
	/** Set the memory location of a symbol.
	 * @param loc Memory location for symbol.
	 */
	public void setLocation(int loc){
		location = loc;
	}
	
	/** Set the usage of a symbol.
	 * @param use Usage for symbol.
	 */
	public void setUsage(Assembler.SymbolUsage use){
		usage = use;
	}
	
	/** Set the length of a symbol.
	 */
	public void setLength(){
		//ask professor about length
		length = label.length();
	}	
	
	/** Set the equated symbol value of a symbol.
	 * @param value Equated symbol value of a symbol.
	 */
	public void setEquValue(int value){
		equValue = value;
	}
	
//	/** 
//	 * @param name
//	 * @param loc
//	 * @param use
//	 */
//	public void getSymbolFields(String name, Integer loc, Assembler.SymbolUsage use){
//		name = label;
//		loc = location;
//		use = usage;
//	}
	
	/** Find the label of a symbol.
	 * @return Symbol label.
	 */
	public String getLabel(){
		return label;
	}
	
	/** Find the memory location of a symbol.
	 * @return Symbol's memory location.
	 */
	public int getLocation(){
		return location;	
	}
	
	/** Find the usage of a symbol.
	 * @return Symbol's usage.
	 */
	public Assembler.SymbolUsage getUsage(){
		return usage;
	}
	
	/** Find the length of a symbol.
	 * @return Symbol's length.
	 */
	public int getLength(){
		return length;
	}
	
	/** Find equated symbol value.
	 * @return Symbol's equated symbol value.
	 */
	public int getEQUValue(){
		return equValue;
	}
}